<?php

if ($handle = opendir(PHOTO_GALLERY_PATH)) {
  while ($file = readdir($handle)) {
      if(isdir($file) && $file != ".." && $file != ".")
        $polozky[count($polozky)] = $file;
  } 
  closedir($handle);
  if(count($polozky) > 0) {
    rsort($polozky);
    reset($polozky);
  } 
}

if($action != ACTION_SAVE_REPORT) {
	if($id_clanku != "") {
	  $query = mysql_query("SELECT * FROM clanek WHERE id_clanku='$id_clanku'");
	  $fetch = MySQL_Fetch_Array($query);
	      $a_cl_nadpis = $fetch["NADPIS"];
	      $a_cl_popis = $fetch["POPIS"];
	      $a_cl_obsah = $fetch["TEXT"];
	      $a_cl_id_utkani = getIdUtkaniForClanek($id_clanku);
	} else {
	  $id_clanku = "";
	  $a_cl_nadpis = "";
	  $a_cl_popis = "";
	  $a_cl_obsah = "";
	  $a_cl_id_utkani = -1;
	}
}

?>

<script language="JavaScript" type="text/javascript" src="./js/calendar.js"></script>
<script type="text/javascript" src="./js/tiny_mce/tiny_mce_gzip.js"></script>

<script type="text/javascript">
createTinyMCEOptimalization();
</script>
<script>
createSimpleWysiwyg("description");
createAdvancedWysiwyg("content");
</script>


<form action="<? echo redirect_str(PAGE_ADMIN_REPORT).action(ACTION_SAVE_REPORT).add_par("id_clanku=".$id_clanku); ?>" method="post">
    
    <fieldset>
      <legend>Úprava článku</legend>
        <label for="a_cl_id_utkani">pro utkání</label><br />
        <select class='text' name='a_cl_id_utkani' size=1>
          <option value='-1'>žádné</option>
          <?
          $query = getMatchesList();
          while($fetch = MySQL_Fetch_Array($query)){
            $id_utkani = $fetch["id_utkani"];
            $text = DateFormat::format($fetch["datum"], DF_DDMMYYYYHHMM)."\t".$fetch["domaci"]." - ".$fetch["hoste"]."\t".$fetch["b_domaci"].":".$fetch["b_hoste"]; 
            if($a_cl_id_utkani == $id_utkani) echo "<option value='$id_utkani' selected>$text</option>";
            else echo "<option value='$id_utkani'>$text</option>";
          }
          ?>
        </select><br /><br>
        
        <label for="a_cl_nadpis">nadpis <span class="star">*</span></label><br />
        <textarea cols=40 rows=1 name='a_cl_nadpis'><? echo $a_cl_nadpis; ?></textarea><br><br>
        
        <label for="a_cl_popis">popisek</label><br />
        <textarea id="description" rows=3 name='a_cl_popis'><? echo $a_cl_popis; ?></textarea><br>
        
        <label for="a_cl_obsah">obsah</label>
        <textarea id="content" rows=40 id="a_cl_obsah" name='a_cl_obsah'><? echo $a_cl_obsah; ?></textarea><br />
        
        <div class="center">
        	<label for="update_flag">aktualizace</label><input id="update_flag" name="a_cl_update" type="checkbox" value="1">
            <input class="button" onmouseover="this.className='button_hover'" 
       			onmouseout="this.className='button'" type="submit" value="ULOŽIT">
       		<a class="button" href="<? echo redirect_str(PAGE_ADMIN_REPORTS); ?>">ZRUŠIT</a>
       	</div>
    </fieldset>
</form>

<label for="foto">kód pro odkaz na fotogalerii</label>
<select class='text' name='foto' id="foto" size=1>
  <?
  for($i = 0; $i < count($polozky); $i++){
    echo "<option value='$polozky[$i]'>".$polozky[$i]."</option>";
  }
  ?>
</select>
<button class="button" onmouseover="this.className='button_hover'" 
	onmouseout="this.className='button'" onclick="MakeLink()">VYTVOŘIT >></button>
<input class='text px270' type='text' id='odkaz' value="" />

<br/><br />

<label for="video">kód pro přehrávač videa</label>
<select class='text' name='video' id="video" size=1>
  <?
  $query = getVideaByReport($id_clanku);
  while($fetch = MySQL_Fetch_Array($query)){
        $id_video = $fetch["ID"];
        $soubor = $fetch["SOUBOR"];
        $nazev = $fetch["NAZEV"];
        echo "<option value='$id_video'>".$nazev."</option>";
  }
  ?>
</select>
<button class="button" onmouseover="this.className='button_hover'" 
	onmouseout="this.className='button'" onclick="<? echo "MakeVideoPlayer($id_video)";?>">VYTVOŘIT >></button>
<input class='text px270' type='text' id='video_tag' value="" />
